home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / shells / bashsrc.zoo / doc / features < prev   
Encoding:
Text File  |  1991-05-29  |  20.2 KB  |  654 lines

  1. -*- text -*-
  2.  
  3. This isn't real documentation, but we have to tell people how this shell is
  4. different from others.
  5.  
  6. NEW STUFF SINCE LAST RELEASE:
  7.  
  8. history_control variable.
  9.  
  10. Set to a value of "ignorespace", it means don't enter lines which begin
  11. with a SPC on the history list.
  12.  
  13. Set to a value of "ignoredups", it means don't enter lines which match
  14. the last entered line.
  15.  
  16. Unset, or any other value than those above mean to save all lines read
  17. by the parser on the history list.
  18.  
  19. END OF NEW STUFF
  20.  
  21.  
  22. When and how bash executes login, rc, and logout files.
  23.  
  24. Login shells:
  25.   On login:
  26.     if /etc/profile exists, source it.
  27.  
  28.     if ~/.bash_profile exists, source it,
  29.       else if ~/.bash_login exists, source it,
  30.         else if ~/.profile exists, source it.
  31.   On logout:
  32.     if ~/.bash_logout exists, source it.
  33.  
  34. Non-login interactive shells:
  35.   On startup:
  36.     if ~/.bashrc exists, source it.
  37.  
  38. Non-interactive shells:
  39.   On startup:
  40.     if the environment variable "ENV" is non-null, source the file
  41.     mentioned there.
  42.  
  43. So, typically, your ~/.bash_profile file contains the line
  44.  
  45.     if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
  46.  
  47. after (or before) any login specific initializations.
  48.  
  49. You can tell if a shell is interactive or not from within your ~/.bashrc
  50. file by examining $PS1; it is unset in non-interactive shells, and set in
  51. interactive shells.  Thus:
  52.  
  53.     if [ "$PS1" = "" ]; then
  54.        echo This shell is not interactive
  55.     else
  56.        echo This shell is interactive
  57.     fi
  58.  
  59. You can ask an interactive bash to not run your .bashrc file, with the
  60. -norc flag.  You can change the name of the .bashrc file to any other
  61. file with -rcfile FILENAME.  You can ask bash to not run your
  62. .bash_profile file with -noprofile.
  63.  
  64. alias: alias [ name [=value] ...]
  65.     Alias with no arguments prints the list of aliases in the form
  66.     name=value on standard output.  An alias is defined for each NAME
  67.     whose VALUE is given.  A trailing space in VALUE causes the next
  68.     word to be checked for alias substitution.  Alias returns true
  69.     unless a NAME is given for which no alias has been defined.
  70.  
  71. unalias: unalias [name ...]
  72.     Remove NAMEs from the list of defined aliases.
  73.  
  74. exec: exec [ [-] file [redirections]]
  75.     Exec FILE, replacing this shell with the specified program.
  76.     If FILE is not specified, the redirections take effect in this
  77.     shell.  If the first argument is `-', then place a dash in the
  78.     zeroith arg passed to FILE.  This is what login does.  If the file
  79.     cannot be exec'ed for some reason, the shell exits, unless the
  80.     shell variable "no_exit_on_failed_exec" exists.
  81.  
  82. help: help [pattern]
  83.     Display helpful information about builtin commands.  If
  84.     PATTERN is specified, gives detailed help on all commands
  85.     matching PATTERN, otherwise a list of the builtins is
  86.     printed.
  87.  
  88. enable: enable [-n name ...]
  89.     Enable and disable builtin shell commands.  This allows
  90.     you to use a disk command which has the same name as a shell
  91.     builtin.  If -n is used, the NAMEs become disabled.  Otherwise
  92.     NAMEs are enabled.  For example, to use /bin/test instead of the
  93.     shell builtin version, you would type `enable -n test'.
  94.  
  95. pushd: pushd [dir | +n]
  96.     Save the current directory on a list and then CD to DIR.
  97.     With no arguments, exchanges the top two directories.
  98.  
  99.     +n   Brings the Nth directory to the top of the list by rotating.
  100.  
  101.     dir  Makes the current working directory be the top of
  102.          the stack, and then cd's to DIR.
  103.  
  104.     You can see the saved directory list with the `dirs' command.
  105.  
  106. popd: popd [+n]
  107.     Pops the directory stack, and cd's to the new top directory.
  108.     The elements are numbered from 0 starting at the first directory
  109.     listed with `dirs'; i.e. `popd' is equivalent to `popd 0'.
  110.  
  111. history: history [n] [ [-w -r] [filename]]
  112.     Display the history list with line numbers.  Lines listed with
  113.     with a `*' have been modified.  Argument of N says to list only
  114.     the last N lines.  Argument `-w' means write out the current
  115.     history file.  `-r' means to read it instead.  If FILENAME is
  116.     given, then use that file, else if $HISTFILE has a value, use
  117.     that, else use ~/.bash_history.
  118.  
  119. ********************
  120. NEW Ulimit Implementation
  121.  
  122. ulimit: ulimit [-cdmstf [limit]]
  123.  Ulimit provides control over the resources available to processes
  124.         started by the shell, on systems that allow such control.  If an
  125.         option is given, it is interpreted as follows:
  126.  
  127.                 -c      the maximum size of core files created
  128.                 -d      the maximum size of a process's data segment
  129.                 -m      the maximum resident set size
  130.                 -s      the maximum stack size
  131.                 -t      the maximum amount of cpu time in milliseconds
  132.                 -f      the maximum size of files created by
  133.  
  134.         If limit is given, it is multiplied by a constant factor (a block
  135.         size, currently 512) and the result becomes the new value of the
  136.         specified resource.  If limit is not given, the current value of
  137.         the specified resource is printed.  If no option is given, then the
  138.         maximum allowable size of a file created by the shell or any of its
  139.         children is printed (equivalent to the -f option).
  140.  
  141. ********************
  142. Tilde expansion:
  143.  
  144. This shell does tilde  expansion:
  145.  
  146. ~ = $HOME
  147. ~/foo = $HOME/foo
  148. ~fred/foo = (fred's home directory)/foo
  149. ~+/foo = $PWD/foo
  150. ~-/foo = $OLDPWD/foo
  151.  
  152.  
  153.  
  154. We have functions.  You can say:
  155.  
  156.      foo () { ls $1 ; }
  157. or
  158.      function foo () { ls $1 ; }
  159.  
  160. Here is the comment next to the decode_prompt_string function.
  161.  
  162. /* Return a string which will be printed as a prompt.  The string
  163.    may contain special characters which are decoded as follows:
  164.    
  165.     \t    the time
  166.     \d    the date
  167.     \n    CRLF
  168.     \s    the name of the shell
  169.     \w    the current working directory
  170.     \u    your username
  171.     \h    the hostname
  172.     \#    the command number of this command
  173.     \!    the history number of this command
  174.     \<octal> character code in octal
  175.     \\    a backslash
  176. */
  177.  
  178. Here is the comment next to the check_mail function, which is called
  179. periodically.  See the documentation for ksh MAILCHECK MAILPATH, etc.
  180. We also have MAIL_WARNING, see below.
  181.  
  182. /* check_mail () is useful for more than just checking mail.  Since it has
  183.    the paranoids dream ability of telling you when someone has read your
  184.    mail, it can just as easily be used to tell you when someones .profile
  185.    file has been read, thus letting one know when someone else has logged
  186.    in.  Pretty good, huh? */
  187.  
  188. /* Check for mail in some files.  If the modification date of any
  189.    of the files in MAILPATH has changed since we last did a
  190.    remember_mail_dates () then mention that the user has mail.
  191.    Special hack:  If the shell variable MAIL_WARNING is on and the
  192.    mail file has been accessed since the last time we remembered, then
  193.    the message "The mail in <mailfile> has been read" is printed. */
  194.  
  195. READLINE:
  196.  
  197. This is the library that handles reading input when using an interactive
  198. shell.  The line editing commands are similar to emacs' line editing commands.
  199. You may change the default key-bindings with a ~/.inputrc file.  Various
  200. programs that use this library may add their own commands and bindings.
  201.  
  202. If you wanted to make M-C-u do universal-argument, then in your ~/.inputrc file
  203. you would put:
  204.  
  205. M-Control-u: universal-argument
  206.  
  207.   or
  208.  
  209. C-Meta-u:    universal-argument
  210.  
  211. You can use the following names for characters: RUBOUT, DEL, ESC,
  212. NEWLINE, SPACE, RETURN, LFD, TAB
  213.  
  214. You can start with a vi-like editing mode by placing
  215.  
  216.     set editing-mode vi
  217.  
  218. in your ~/.inputrc file.
  219.  
  220. You can have readline use a single line for display, scrolling the input
  221. between the two borders by placing
  222.  
  223.     set horizontal-scroll-mode On
  224.  
  225. in your ~/.inputrc file.
  226.  
  227. The following is a list of the names of the commands and the default
  228. key-strokes to get them.
  229.  
  230. COMMANDS FOR MOVING:
  231.  
  232. beginning-of-line (C-a)
  233.     Move to the start of the current line.
  234.  
  235. end-of-line    (C-e)
  236.     Move to the end of the line.
  237.  
  238. forward-char    (C-f)
  239.     Move forward a character.
  240.  
  241. backward-char    (C-b)
  242.     Move back a character.
  243.  
  244. forward-word    (M-f)
  245.     Move forward to the end of the next word.
  246.  
  247. backward-word    (M-b)
  248.     Move back to the start of this, or the previous, word.
  249.  
  250. clear-screen    (C-l)
  251.     Clear the screen leaving the current line at the top of the screen.
  252.  
  253.  
  254. COMMANDS FOR MANIPULATING THE HISTORY:
  255.  
  256. accept-line    (Newline, Return)
  257.     Accept the line regardless of where the cursor is.  If this line is
  258.     non-empty, add it too the history list.  If this line was a history
  259.     line, then restore the history line to its original state.
  260.  
  261. previous-history (C-p)
  262.     Move `up' through the history list.
  263.  
  264. next-history    (C-n)
  265.     Move `down' through the history list.
  266.  
  267. beginning-of-history (M-<)
  268.     Move to the first line in the history.
  269.  
  270. end-of-history    (M->)
  271.     Move to the end of the input history, i.e., the line you are entering!
  272.  
  273. reverse-search-history (C-r)
  274.     Search backward starting at the current line and moving `up' through
  275.     the history as necessary.  This is an incremental search.  Maybe I
  276.     should have reg-exp searches as well?
  277.  
  278. forward-search-history (C-s)
  279.     Search forward starting at the current line and moving `down' through
  280.     the the history as neccessary.
  281.  
  282. expand-line (M-C-e)
  283.     Expand the line the way that the shell will when it reads it.  This
  284.     does alias and history expansion.  See HISTORY EXPANSION below.
  285.  
  286.  
  287. COMMANDS FOR CHANGING TEXT:
  288.  
  289. delete-char    (C-d)
  290.     Delete the character under the cursor.  If the cursor is at the
  291.     beginning of the line, and there are no characters in the line, and
  292.     the last character typed was not C-d, then return EOF.
  293.  
  294. backward-delete-char (Rubout)
  295.     Delete the character behind the cursor.  A numeric arg says to kill
  296.     the characters instead of deleting them.
  297.  
  298. quoted-insert    (C-q, C-v)
  299.     Add the next character that you type to the line verbatim.  This is
  300.     how to insert things like C-q for example.
  301.  
  302. tab-insert    (M-TAB)
  303.     Insert a tab character.
  304.  
  305. self-insert    (a, b, A, 1, !, ...)
  306.     Insert yourself.
  307.  
  308. transpose-chars (C-t)
  309.     Drag the character before point forward over the character at point.
  310.     Point moves forward as well.  If point is at the end of the line, then
  311.     transpose the two characters before point.  Negative args don't work.
  312.  
  313. transpose-words    (M-t)
  314.     Drag the word behind the cursor past the word in front of the cursor
  315.     moving the cursor over that word as well.
  316.  
  317. upcase-word    (M-u)
  318.     Uppercase the current (or following) word.  With a negative argument,
  319.     do the previous word, but do not move point.
  320.  
  321. downcase-word    (M-l)
  322.     Lowercase the current (or following) word.  With a negative argument,
  323.     do the previous word, but do not move point.
  324.  
  325. capitalize-word    (M-c)
  326.     Uppercase the current (or following) word.  With a negative argument,
  327.     do the previous word, but do not move point.
  328.  
  329. KILLING AND YANKING:
  330.  
  331. kill-line    (C-k)
  332.     Kill the text from the current cursor position to the end of the line.
  333.     This saves the killed text on the kill-ring.  (see below)
  334.     
  335. backward-kill-line ()
  336.     Kill backward to the beginning of the line.  This is normally unbound.
  337.  
  338. kill-word    (M-d)
  339.     Kill from the cursor to the end of the current word, or if between
  340.     words, to the end of the next word.
  341.  
  342. backward-kill-word (M-Rubout)
  343.     Kill the word behind the cursor.
  344.  
  345. unix-line-discard (C-u)
  346.     Do what C-u used to do in Unix line input.  We save the killed text on
  347.     the kill-ring, though.
  348.  
  349. unix-word-rubout (C-w)
  350.     Do what C-w used to do in Unix line input.  The killed text is saved
  351.     on the kill-ring.  This is different than backward-kill-word because
  352.     the word boundaries differ.
  353.  
  354. yank        (C-y)
  355.     Yank the top of the kill ring into the buffer at point.
  356.  
  357. yank-pop    (M-y)
  358.     Rotate the kill-ring, and yank the new top.  You can only do this if
  359.     the prior command is yank or yank-pop.
  360.     
  361. ARGUMENTS:
  362.  
  363. digit-argument    (M-0, M-1, ... M--)
  364.     Add this digit to the argument already accumulating, or start a new
  365.     argument.  M-- starts a negative argument.
  366.  
  367. universal-argument ()
  368.     Do what C-u does in emacs.  By default, this is not bound.
  369.     
  370. COMPLETING:
  371.  
  372. complete    (TAB)
  373.     Attempt to do completion on the text before point.  In the shell,
  374.     filenames and commands are completed on.
  375.  
  376. possible-completions (M-?)
  377.     List the possible completions of the text before point.
  378.  
  379. MISCELLANEOUS:
  380. abort        (C-g)
  381.     Ding!  Stops things.
  382.  
  383. do-uppercase-version (M-a, M-b, ...)
  384.     Run the command that is bound to your uppercase brother.
  385.     
  386. prefix-meta    (ESC)
  387.     Make the next character that you type be Meta-fied.  This is for
  388.     people without a meta key.  ESC-f is equivalent to Meta-f.
  389.  
  390. undo        (C-_)
  391.     Incremental undo, separately remembered for each line.
  392.  
  393. revert-line    (M-r)
  394.     Undo all changes made to this line.  This is like typing the `undo'
  395.     command enough times to get back to the beginning.
  396.  
  397. The shell has several variables which are there just for controlling the
  398. behavior of the interactive shell.  Here they are:
  399.  
  400. HISTFILE: The name of the file that the command history is saved in.
  401.  
  402. HISTSIZE: If set, this is the maximum number of commands to remember
  403.       in the history.
  404.  
  405. histchars: The two characters which control history expansion and
  406.       tokenization.  The first character is the history_expansion_char,
  407.       that is, the character which signifies the start of a history
  408.       expansion, normally '!'.  The second character is the character
  409.       which signifies the remainder of the line is a comment, when found
  410.       as the first character of a word.
  411.  
  412. hostname_completion_file:
  413.       Contains the name of a file in the same format as /etc/hosts
  414.       that should be read when the shell needs to complete a
  415.       hostname.  You can change the file interactively; the next
  416.       time you want to complete a hostname Bash will add the
  417.       contents of the new file to the already existing database.
  418.  
  419. MAILCHECK: How often (in seconds) that the shell should check for mail
  420.        in the file(s) specified in MAILPATH.
  421.  
  422. MAILPATH: Colon separated list of pathnames to check for mail in.  You can
  423.       also specify what message is printed by separating the pathname from
  424.       the message with a `?'.  $_ stands for the name of the current
  425.       mailfile.  e.g.
  426.  
  427. MAILPATH='/usr/spool/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"'
  428.  
  429. ignoreeof:
  430. IGNOREEOF:
  431.     Controls the action of the shell on receipt of an EOF character
  432.     as the sole input.  If set, then the value of it is the number
  433.     of EOF characters that can be seen in a row as sole input characters
  434.     before the shell will exit.  If the variable exists but does not
  435.     have a numeric value (or has no value) then the default is 10.
  436.     if the variable does not exist, then EOF signifies the end of 
  437.     input to the shell.  This is only in effect for interactive shells.
  438.  
  439. auto_resume:
  440.     This variable controls how the shell interacts with the user and
  441.     job control.  If this variable exists then single word simple
  442.     commands without redirects are treated as candidates for resumption
  443.     of an existing job.  There is no ambiguity allowed; if you have
  444.     more than one job beginning with the string that you have typed, then
  445.     the most recently accessed job will be selected.
  446.  
  447. no_exit_on_failed_exec:
  448.     If this variable exists, the shell will not exit in the case that it
  449.     couldn't execute the file specified in the `exec' command.
  450.  
  451.  
  452. PROMPT_COMMAND:
  453.     If present, this contains a string which is a command to execute
  454.     before the printing of each top-level prompt.
  455.  
  456. nolinks:
  457.     If present, says not to follow symbolic links when doing commands
  458.     that change the current working directory.  By default, bash follows
  459.     the logical chain of directories when performing `cd' type commands.
  460.     For example, if /usr/sys is a link to /usr/local/sys then:
  461.  
  462.     cd /usr/sys; echo $PWD -> /usr/sys
  463.     cd ..; pwd -> /usr
  464.  
  465.     if `nolinks' is present, then:
  466.  
  467.     cd /usr/sys; echo $PWD -> /usr/local/sys
  468.     cd ..; pwd -> /usr/local
  469.  
  470. **********************************************************************
  471. Shell Command Line Options
  472.  
  473. Along with the single character shell command-line options (documented in
  474. `set') there are several other options that you can use.  These options must
  475. appear on the command line before the single character command options to be
  476. recognized.
  477.  
  478. -norc
  479.     Don't load ~/.bashrc init file. (Default if shell name is `sh').
  480.  
  481. -rcfile FILENAME
  482.     Load FILENAME init file (instead ~/.bashrc).
  483.  
  484. -noprofile
  485.     Don't load ~/.bash_profile (or /etc/profile).
  486.  
  487. -version
  488.     Display the version number of this shell.
  489.  
  490. -login
  491.     Make this shell act as if it were directly invoked from login.
  492.     This is equivalent to "exec - bash" but can be issued from
  493.     another shell, such as csh.  If you wanted to replace your
  494.     current login shell with a bash login shell, you would say
  495.     "exec bash -login".
  496.  
  497. -nobraceexpansion
  498.     Do not preform curly brace expansion (foo{a,b} -> fooa foob).
  499.  
  500. -nolineeding
  501.     Do not use the GNU Readline library to read interactive text
  502.     lines.
  503.  
  504. **********************************************************************
  505.  
  506. History Expansion:
  507.  
  508. The following text is taken directly from the history.texinfo file, node
  509. Interactive Use.
  510.  
  511. Interactive Use
  512. ***************
  513.  
  514. History Expansion
  515. =================
  516.  
  517. The shell supports a history expansion feature that is similar to
  518. the history expansion in Csh.  The following text describes what
  519. syntax features are available.
  520.  
  521. History expansion takes place in two parts.  The first is
  522. determining which line from the previous history to use during
  523. substitution.  The second is to select portions of that line for
  524. inclusion into the current one.  The line selected from the
  525. previous history is called the "event", and the portions of that
  526. line that are acted upon are called "words".  The line is broken
  527. into words in the same fashion that the Bash shell does, so that
  528. several English (or Unix) words surrounded by quotes are considered
  529. as one word.
  530.  
  531. Event Designators
  532. -----------------
  533.  
  534. An event designator is a reference to a command line entry in the
  535. history list.
  536.  
  537. `!'
  538.      Start a history subsititution, except when followed by a SPC,
  539.      TAB, RET, = or (.
  540.  
  541. `!!'
  542.      Refer to the previous command.  This is a synonym for `!-1'.
  543.  
  544. `!n'
  545.      Refer to command line N.
  546.  
  547. `!-n'
  548.      Refer to the current command line minus N.
  549.  
  550. `!string'
  551.      Refer to the most recent command starting with STRING.
  552.  
  553. `!?string[?]'
  554.      Refer to the most recent command containing STRING.
  555.  
  556. Word Designators
  557. ----------------
  558.  
  559. Words  A : separates the event specification from the word
  560. designator.  It can be omitted if the word designator begins with a
  561. ^, $, * or %.  Words are numbered from the beginning of the line,
  562. with the first word being denoted by a 0 (zero).
  563.  
  564. `#'
  565.      The entire command line typed so far.  This means the current
  566.      command, not the previous command, so it really isn't a word
  567.      designator, and doesn't belong in this section.
  568.  
  569. `0 (zero)'
  570.      The zero'th word.  For most applications, this is the command
  571.      word.
  572.  
  573. `n'
  574.      The N'th word.
  575.  
  576. `^'
  577.      The first argument.  that is, word 1.
  578.  
  579. `$'
  580.      The last argument.
  581.  
  582. `%'
  583.      The word matched by the most recent `?string?' search.
  584.  
  585. `x-y'
  586.      A range of words; `-Y' Abbreviates `0-Y'.
  587.  
  588. `*'
  589.      All of the words, excepting the zero'th.  This is a synonym
  590.      for `1-$'.  It is not an error to use * if there is just one
  591.      word in the event.  The empty string is returned in that case.
  592.  
  593. Modifiers
  594. ---------
  595.  
  596. After the optional word designator, you can add a sequence of one
  597. or more of the following modifiers, each preceded by a :.
  598.  
  599. `h'
  600.      Remove a trailing pathname component, leaving only the head.
  601.  
  602. `r'
  603.      Remove a trailing suffix of the form ".xxx", leaving the
  604.      basename.
  605.  
  606. `e'
  607.      Remove all but the suffix.
  608.  
  609. `t'
  610.      Remove all leading  pathname  components, leaving the tail.
  611.  
  612. `p'
  613.      Print the new command but do not execute it.  This takes
  614.      effect immediately, so it should be the last specifier on the
  615.      line.
  616.  
  617. ------------------------------------------------------------
  618. More redirections than other sh's.  Isn't that great?
  619.  
  620.     command &>file
  621.  
  622. redirects both stdout and stderr into FILE.
  623.  
  624. ------------------------------------------------------------
  625. Curly Brace Expansion
  626.  
  627.     foo{a,b}-> fooa foob
  628.  
  629. ----------------------------------------
  630.  
  631. Command Substitution with "$( commands ... )
  632.  
  633. The shell now supports $(command) command substitution.  This is akin to
  634. the older (and still supported) style of command substitution:
  635. `command`.
  636.  
  637.     Here is one way to get your hostname isolated:
  638.  
  639.     using $(): echo $(basename $(hostname) $(domainname))
  640.  
  641.     using ``:  echo `basename \`hostname\` \`domainname\``
  642.  
  643. type: type [-type | -path] [name ...]
  644.     For each NAME, indicate how it would be interpreted if used as a
  645.     command name.
  646.  
  647.     If the -type flag is used, returns a single word which is one of
  648.     `alias', `function', `builtin', `file' or `', if NAME is an
  649.     alias, shell function, shell builtin, disk file, or unfound,
  650.     respectively.
  651.  
  652.     If the -path flag is used, either returns the name of the disk file
  653.     that would be exec'ed, or nothing if -type wouldn't return `file'.
  654.